class Solution(object):
    def checkPowersOfThree(self, n):
        while n > 0:
            t = n % 3
            if t == 2:
                return False
            n = n // 3
        return True
